#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;
const int MAXM = 1e5 + 10;

struct Seg{
    int l,r;
    Seg(int l, int r):l(l),r(r){}
    bool operator<(const Seg& t){
        if(l==t.l)return r < t.r;
        return l < t.l;
    }
};

vector<Seg> S;
int p[MAXM];

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--){
        int n,m,L,V,ans1 = 0, ans2 = 0;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        S.clear();
        for(int i = 0; i < n; ++i){
            int d,v,a;
            scanf("%d%d%d",&d,&v,&a);
            if(a==0){
                if(v > V)S.push_back(Seg(d,L));
            }else if(a<0){
                if(v<=V)continue;
                int x = (V*V-v*v+1)/(2*a)+d;
                S.push_back(Seg(d,min(L,x)));

            }else{
                int x = (V*V-v*v)/(2*a)+d;
                x++;
                if(x>L)continue;
                S.push_back(Seg(x,L));
            }
        }
        for(int i = 0; i < m; ++i)scanf("%d",&p[i]);
        sort(S.begin(),S.end());
        for(int i = S.size()-1,j = m-1; i >=0 && j >=0;--i){
            while(j > 0&&p[j-1]>=S[i].l)--j;
            if(p[j]<S[i].l || p[j] > S[i].r){
                S[i] = Seg(L+1,L+1);
            }else ans1++;
        }
        int min_p = L+1;
        for(int i = S.size()-1,j = m-1; i >=0 && j >=0;--i){
            if(S[i].l==L+1)continue;
            if(min_p <= S[i].r)continue;
            while(j > 0&&p[j-1]>=S[i].l)--j;
            if(p[j] <= S[i].r){
                ans2++;
                min_p = p[j];
            }
        }
        printf("%d %d\n",ans1,m-ans2);
    }
	return 0;
}
